DECLARE SUB ActivateCapsLock ()

  CLS : RANDOMIZE TIMER
  PALETTE 0, 8
  LOCATE 4, 30: PRINT "KCCK Designs presents:"
  LOCATE 9, 25: COLOR 15, 0, 8: PRINT "A production of epic proportions.": SLEEP 2
10 CLS : PALETTE 0, 8: COLOR 9, 0, 8
   LOCATE 6, 34: PRINT "SUPER STAR TREK"
   COLOR 7, 0, 8: PRINT TAB(37); "Ver. 2.0"
   LOCATE 16, 40: PRINT "adapted by Chris Kugler"
   PRINT TAB(40); "(C) copyright 1996, KCCK Designs"
   PRINT TAB(40); "all rights reserved": SLEEP 1
   LOCATE 23, 1: PRINT "Press any key to continue..."
62 a$ = INKEY$: IF a$ = "" THEN 62
63 CLS : PRINT : PRINT : PRINT : PRINT
   INPUT "What is your last name, Captain"; name$
   PRINT : INPUT "What is your ship's designation"; ship$
   ActivateCapsLock
   PRINT : INPUT "Would you like instructions (Y/N)"; m$
   IF m$ = "Y" OR m$ = "YES" THEN GOSUB 10000
    CLS : PRINT : PRINT : PRINT
    z$ = "                         "
    DIM g(8, 8), c(9, 2), k(3, 3), N(3), z(8, 8), d(8)
    t = INT(RND(1) * 20 + 20) * 100: t0 = t: t9 = 25 + INT(RND(1) * 10): d0 = 0: e = 3000: e0 = e
    p = 10: p0 = p: s9 = 200: s = 0: b9 = 0: k9 = 0: x$ = "": x0$ = " is "
    DEF fnd (d) = SQR((k(i, 1) - s1) ^ 2 + (k(i, 2) - s2) ^ 2)
    DEF fnr (r) = INT(RND(r) * 7.98 + 1.01)
    REM initialize positon
    q1 = fnr(1): q2 = fnr(1): s1 = fnr(1): s2 = fnr(1)
    FOR i = 1 TO 9: c(i, 1) = 0: c(i, 2) = 0: NEXT i
    c(3, 1) = -1: c(2, 1) = -1: c(4, 1) = -1: c(4, 2) = -1: c(5, 2) = -1: c(6, 2) = -1
    c(1, 2) = 1: c(2, 2) = 1: c(6, 1) = 1: c(7, 1) = 1: c(8, 1) = 1: c(8, 2) = 1: c(9, 2) = 1
    FOR i = 1 TO 8: d(i) = 0: NEXT i
    a1$ = "NAVSRSLRSPHATORSHEDAMCOMXXX"
    REM setup galaxy
    REM k3=#Romulans b3=#starbases s3=#stars
    FOR i = 1 TO 8: FOR j = 1 TO 8: k3 = 0: z(i, j) = 0: r1 = RND(1)
    IF r1 > .98 THEN k3 = 3: k9 = k9 + 3: GOTO 980
    IF r1 > .95 THEN k3 = 2: k9 = k9 + 2: GOTO 980
    IF r1 > .8 THEN k3 = 1: k9 = k9 + 1
980 b3 = 0: IF RND(1) > .9 THEN b3 = 1: b9 = b9 + 1
     g(i, j) = k3 * 100 + b3 * 10 + fnr(1): NEXT j: NEXT i: IF k9 > t9 THEN t9 = k9 + 1
     IF b9 <> 0 THEN 1200
     IF g(q1, q2) < 200 THEN g(q1, q2) = g(q1, q2) + 100: k9 = k9 + 1
     b9 = 1: g(q1, q2) = g(q1, q2) + 10: q1 = fnr(1): q2 = fnr(1)
1200 k7 = k9: IF b9 <> 1 THEN x$ = "s": x0$ = " are "
     PRINT : PRINT "Captain "; name$; ", your orders are as follows:"
     PRINT "     Destroy the"; k9; "Romulan warships that have invaded"
     PRINT "     the galaxy before they can attack Federation Headquarters"
     PRINT "     on stardate"; t0 + t9; ".  This gives you"; t9; "days.  There"; x0$
     PRINT "    "; b9; "starbase"; x$; " in the galaxy for resupplying your ship."
     PRINT : PRINT : PRINT : PRINT "Press any key to continue..."
1300 a$ = INKEY$: IF a$ = "" THEN 1300
     CLS : REM new quadrent
1320 z4 = q1: z5 = q2: k3 = 0: b3 = 0: s3 = 0: g5 = 0: d4 = .5 * RND(1): z(q1, q2) = g(q1, q2)
     IF q1 < 1 OR q1 > 8 OR q2 < 1 OR q2 > 8 THEN 1600
     GOSUB 9030: PRINT : IF t0 <> t THEN 1490
     PRINT "Your mission begins with your starship located"
     PRINT "in the galactic quadrent, '"; g2$; "'.": GOTO 1500
1490 PRINT "Now entering "; g2$; " quadrent..."
1500 PRINT : k3 = INT(g(q1, q2) * .01): b3 = INT(g(q1, q2) * .1) - 10 * k3
     s3 = g(q1, q2) - 100 * k3 - 10 * b3: IF k3 = 0 THEN 1590
     COLOR 20, 0, 4: PRINT "Combat Area      Condition Red": COLOR 7, 0, 8: IF s > 200 THEN 1590
     COLOR 15, 0, 4: PRINT "   Shields Dangerously Low": COLOR 7, 0, 8
1590 FOR i = 1 TO 3: k(i, 1) = 0: k(i, 2) = 0: NEXT i
1600 FOR i = 1 TO 3: k(i, 3) = 0: NEXT i: q$ = z$ + z$ + z$ + z$ + z$ + z$ + z$ + LEFT$(z$, 17)
     REM position starship, Romulans
     REM position starbases, stars
     a$ = "<*>": z1 = s1: z2 = s2: GOSUB 8670: IF k3 < 1 THEN 1820
     FOR i = 1 TO k3: GOSUB 8590: a$ = "+R+": z1 = r1: z2 = r2
     GOSUB 8670: k(i, 1) = r1: k(i, 2) = r2: k(i, 3) = s9 * (.5 + RND(1)): NEXT i
1820 IF b3 < 1 THEN 1910
     GOSUB 8590: a$ = ">B<": z1 = r1: b4 = r1: z2 = r2: b5 = r2: GOSUB 8670
1910 FOR i = 1 TO s3: GOSUB 8590: a$ = " * ": z1 = r1: z2 = r2: GOSUB 8670: NEXT i
1980 GOSUB 6430
1990 IF s + e > 10 THEN IF e > 10 OR d(7) = 0 THEN 2060
     PRINT : COLOR 20, 0, 4: PRINT "  ** Fatal Error **"
     COLOR 7, 0, 8: PRINT "You've just stranded your ship in space."
     PRINT "You have insufficient maneuvering energy, and shield control"
     PRINT "is presently incapable of cross-circuiting to the engine room!": GOTO 6220
2060 INPUT "Command"; a$
     FOR i = 1 TO 9: IF LEFT$(a$, 3) <> MID$(a1$, 3 * i - 2, 3) THEN 2160
     ON i GOTO 2300, 1980, 4000, 4260, 4700, 5530, 5690, 7290, 6270
2160 NEXT i: PRINT "Enter one of the following:"
     PRINT "  NAV  (to set course)"
     PRINT "  SRS  (short-range sensor scan)"
     PRINT "  LRS  (long-range sensor scan)"
     PRINT "  PHA  (fire phasers)"
     PRINT "  TOR  (fire photon torpedoes)"
     PRINT "  SHE  (raise or lower shields)"
     PRINT "  DAM  (damage control report)"
     PRINT "  COM  (call on library-computer)"
     PRINT "  XXX  (resign your command)": PRINT : GOTO 1990
     REM course control begins here
2300 INPUT "Course (0-9)"; c1: IF c1 = 9 THEN c1 = 1
     IF c1 >= 1 AND c1 < 9 THEN 2350
     PRINT "  Helm reports, 'Incorrect course data, sir!'": GOTO 1990
2350 x$ = "8": IF d(1) < 0 THEN x$ = "0.2"
     PRINT "Warp Factor (0-"; x$; ")"; : INPUT w1: IF d(1) < 0 AND w1 > .2 THEN 2470
     IF w1 > 0 AND w1 <= 8 THEN 2490
     IF w1 = 0 THEN 1990
     PRINT "Lt. LaForge reports, 'The engines can't handle ";
     PRINT "warp"; w1; ", sir!'": GOTO 1990
2470 PRINT "Warp engines are damaged.  Maximum speed = Warp 0.2": GOTO 1990
2490 N = INT(w1 * 8 + .5): IF e - N >= 0 THEN 2590
     PRINT "Lt. LaForge reports, 'Insufficient energy available for"
     PRINT "  maneuvering at warp"; w1; ", sir!'"
     IF s < N - e OR d(7) < 0 THEN 1990
     PRINT "Worf acknowledges"; s; "units of energy deployed to shields."
     GOTO 1990
     REM Romulans fire/move on starship...
2590 FOR i = 1 TO k3: IF k(i, 3) = 0 THEN 2700
     a$ = "   ": z1 = k(i, 1): z2 = k(i, 2): GOSUB 8670: GOSUB 8590
     k(i, 1) = z1: k(i, 2) = z2: a$ = "+R+": GOSUB 8670
2700 NEXT i: GOSUB 6000: d1 = 0: v6 = w1: IF w1 >= 1 THEN d6 = 1
     FOR i = 1 TO 6: IF d(i) >= 0 THEN 2880
     d(i) = d(i) + d6: IF d(i) > -.1 AND d(i) < 0 THEN d(i) = -.1: GOTO 2880
     IF d(i) < 0 THEN 2880
     IF d1 <> 1 THEN d1 = 1: PRINT "Damage Control Report:   ";
     PRINT TAB(8); : r1 = i: GOSUB 8790: PRINT g2$; " repair completed."
2880 NEXT i: IF RND(1) > .2 THEN 3070
     r1 = fnr(1): IF RND(1) >= .6 THEN 3000
     d(r1) = d(r1) - (RND(1) * 5 + 1): PRINT "Damage Control Report:   ";
     GOSUB 8790: PRINT g2$; " damaged": PRINT : GOTO 3070
3000 d(r1) = d(r1) + RND(1) * 3 + 1: PRINT "Damage Control Report:   ";
     GOSUB 8790: PRINT g2$; " state of repair improved.": PRINT
     REM begin moving starship
3070 a$ = "   ": z1 = INT(s1): z2 = INT(s2): GOSUB 8670
     x1 = c(c1, 1) + (c(c1 + 1, 1) - c(c1, 1)) * (c1 - INT(c1)): x = s1: y = s2
     x2 = c(c1, 2) + (c(c1 + 1, 2) - c(c1, 2)) * (c1 - INT(c1)): q4 = q1: q5 = q2
     FOR i = 1 TO N: s1 = s1 + x1: s2 = s2 + x2: IF s1 < 1 OR s1 >= 9 OR s2 < 1 OR s2 >= 9 THEN 3500
     s8 = INT(s1) * 24 + INT(s2) * 3 - 26: IF MID$(q$, s8, 2) = "  " THEN 3360
     s1 = INT(s1 - x1): s2 = INT(s2 - x2): PRINT "Warp engines shut down at ";
     PRINT "sector"; s1; ","; s2; "due to bad navigation.": GOTO 3370
3360 NEXT i: s1 = INT(s1): s2 = INT(s2)
3370 a$ = "<*>": z1 = INT(s1): z2 = INT(s2): GOSUB 8670: GOSUB 3910: t8 = 1
     IF w1 < 1 THEN t8 = .1 * INT(10 * w1)
     t = t + t8: IF t > t0 + t9 THEN 6220
     REM see if docked, then get command
     GOTO 1980
     REM exceeded quadrent limits
3500 x = 8 * q1 + x + N * x1: y = 8 * q2 + y + N * x2: q1 = INT(x / 8): q2 = INT(y / 8): s1 = INT(x - q1 * 8)
     s2 = INT(y - q2 * 8): IF s1 = 0 THEN q1 = q1 - 1: s1 = 8
     IF s2 = 0 THEN q2 = q2 - 1: s2 = 8
     x5 = 0: IF q1 < 1 THEN x5 = 1: q1 = 1: s1 = 1
     IF q1 > 8 THEN x5 = 1: q1 = 8: s1 = 8
     IF q2 < 1 THEN x5 = 1: q2 = 1: s2 = 1
     IF q2 > 8 THEN x5 = 1: q2 = 8: s2 = 8
     IF x5 = 0 THEN 3860
     PRINT "Sub-space message from Starfleet Command:"
     PRINT "  'Permission to attempt crossing of galactic perimeter"
     PRINT "  is hereby denied.  Shut down your engines.'"
     PRINT "Lt. LaForge reports, 'Warp engines shut down at sector"
     PRINT "  "; s1; ","; s2; "of quadrent"; q1; ","; q2; ", sir.'"
     IF t > t0 + t9 THEN 6220
3860 IF 8 * q1 + q2 = 8 * q4 + q5 THEN 3370
     t = t + 1: GOSUB 3910: GOTO 1320
     REM maneuver energy s/r **
3910 e = e - N - 10: IF e >= 0 THEN RETURN
     PRINT "Power transfered from shields to complete the maneuver."
     s = s + e: e = 0: IF s <= 0 THEN s = 0
     RETURN
     REM long-range sensor scan code
4000 IF d(3) < 0 THEN PRINT "Long-range sensors are inoperable.": GOTO 1990
     PRINT "Long-range scan for quadrent"; q1; ","; q2; ":"
     o1$ = "-------------------": PRINT o1$
     FOR i = q1 - 1 TO q1 + 1: N(1) = -1: N(2) = -2: N(3) = -3: FOR j = q2 - 1 TO q2 + 1
     IF i > 0 AND i < 9 AND j > 0 AND j < 9 THEN N(j - q2 + 2) = g(i, j): z(i, j) = g(i, j)
     NEXT j: FOR l = 1 TO 3: PRINT ":  "; : IF N(l) < 0 THEN PRINT "*** "; : GOTO 4230
     PRINT RIGHT$(STR$(N(l) + 1000), 3); " ";
4230 NEXT l: PRINT ":": PRINT o1$: NEXT i: GOTO 1990
     REM phaser control
4260 IF d(4) < 0 THEN PRINT "Phasers inoperative": GOTO 1990
     IF k3 > 0 THEN 4330
4270 PRINT "Data reports, 'Sensors show no enemy ships in this quadrent.'": GOTO 1990
4330 IF d(8) < 0 THEN PRINT "Computer failure hampens accuracy."
     PRINT "Phasers locked on target;  ";
4360 PRINT "Energy available="; e; "units."
     INPUT "Number of units to fire"; x: IF x <= 0 THEN 1990
     IF e - x < 0 THEN 4360
     e = e - x: IF d(7) < 0 THEN x = x * RND(1)
     h1 = INT(x / k3): FOR i = 1 TO 3: IF k(i, 3) <= 0 THEN 4670
     h = INT((h1 / fnd(0)) * (RND(1) + 2)): IF h > .15 * k(i, 3) THEN 4530
     PRINT "Sensors show no damage to enemy at "; k(i, 1); ","; k(i, 2): GOTO 4670
4530 k(i, 3) = k(i, 3) - h: PRINT h; "unit hit on Romulan at sector"; k(i, 1); ",";
     PRINT k(i, 2): IF k(i, 3) <= 0 THEN COLOR 20, 0, 4: IF k(i, 3) <= 0 THEN PRINT "*** Romulan Destroyed ***": COLOR 7, 0, 8: GOTO 4580
     PRINT "   (Sensors show"; k(i, 3); "units remaining)": GOTO 4670
4580 k3 = k3 - 1: k9 = k9 - 1: z1 = k(i, 1): z2 = k(i, 2): a$ = "   ": GOSUB 8670
     k(i, 3) = 0: g(q1, q2) = g(q1, q2) - 100: z(q1, q2) = g(q1, q2): IF k9 <= 0 THEN 6370
4670 NEXT i: GOSUB 6000: GOTO 1990
     REM torpedo code begins here
4700 IF p <= 0 THEN PRINT "All photon torpedoes expended!": GOTO 1990
     IF d(5) < 0 THEN PRINT "Photon tubes are not operational.": GOTO 1990
4760 INPUT "Photon torpedo course (1-9)"; c1: IF c1 = 9 THEN c1 = 1
     IF c1 >= 1 AND c1 < 9 THEN 4850
     PRINT "Lt. Worf reports, 'Incorrect course data, sir!'"
     GOTO 1990
4850 x1 = c(c1, 1) + (c(c1 + 1, 1) - c(c1, 1)) * (c1 - INT(c1)): e = e - 2: p = p - 1
     x2 = c(c1, 2) + (c(c1 + 1, 2) - c(c1, 2)) * (c1 - INT(c1)): x = s1: y = s2
     PRINT "Torpedo track:"
4920 x = x + x1: y = y + x2: x3 = INT(x + .5): y3 = INT(y + .5)
     IF x3 < 1 OR x3 > 8 OR y3 < 1 OR y3 > 8 THEN 5490
     PRINT "               "; x3; ","; y3: a$ = "   ": z1 = x: x2 = y: GOSUB 8830
     IF z3 <> 0 THEN 4920
     a$ = "+R+": z1 = x: z2 = y: GOSUB 8830: IF z3 = 0 THEN 5210
     COLOR 20, 0, 4: PRINT "  *** Romulan Destroyed ***": COLOR 7, 0, 8: k3 = k3 - 1: k9 = k9 - 1: IF k9 <= 0 THEN 6370
     FOR i = 1 TO 3: IF x3 = k(i, 1) AND y3 = k(i, 2) THEN 5190
     NEXT i: i = 3
5190 k(i, 3) = 0: GOTO 5430
5210 a$ = " * ": z1 = x: z2 = y: GOSUB 8830: IF z3 = 0 THEN 5280
     PRINT "Star at"; x3; ","; y3; "absorbed torpedo energy.": GOSUB 6000: GOTO 1990
5280 a$ = ">B<": z1 = x: z2 = y: GOSUB 8830: IF z3 = 0 THEN 4760
     COLOR 19, 0, 4: PRINT "  *** Starbase Destroyed ***": COLOR 7, 0, 8: b3 = b3 - 1: b9 = b9 - 1
     IF b9 < 0 OR k9 > t - t0 - t9 THEN 5400
     PRINT "That does it, Captain "; name$; "!  You are relieved of command"
     PRINT " and sentenced to 1000 stardates of hard labor on Cygnus IV!"
     GOTO 6270
5400 PRINT "Starfleet command is reviewing your record to consider court marshal!"
     d0 = 0
5430 z1 = x: z2 = y: a$ = "   ": GOSUB 8670
     g(q1, q2) = k3 * 100 + b3 * 10 + s3: z(q1, q2) = g(q1, q2): GOSUB 6000: GOTO 1990
5490 PRINT "Torpedo missed...": GOSUB 6000: GOTO 1990
     REM shield control
5530 IF d(7) < 0 THEN PRINT "Shield control inoperable": GOTO 1990
     PRINT "Energy available="; e + s; : INPUT "Number of units to shields"; x
     IF x < 0 OR s = x THEN COLOR 15, 0, 8: PRINT "<Shields Unchanged>": COLOR 7, 0, 8: GOTO 1990
     IF x <= e + s THEN 5630
     PRINT "Shield control reports, 'This is not the Federation treasury!'"
     COLOR 15, 0, 8: PRINT "<Shields Unchanged>": COLOR 7, 0, 8: GOTO 1990
5630 e = e + s - x: s = x: PRINT "Shield control room report:"
     PRINT "  'Shields now at"; INT(s); "units per your command.'": GOTO 1990
     REM damage control
5690 IF d(6) >= 0 THEN 5910
     PRINT "Damage control report not available": IF d0 = 0 THEN 1990
5720 d3 = 0: FOR i = 1 TO 8: IF d(i) < 0 THEN d3 = d3 + .1
     NEXT i: IF d3 = 0 THEN 1990
     PRINT : d3 = d3 + d4: IF d3 >= 1 THEN d3 = .9
     PRINT "Technicians standing by to make repairs to your ship."
     PRINT "Estimated time to repair:"; .01 * INT(100 * d3); "stardates."
     INPUT "Will you authorize the repair order (Y/N)"; a$
     IF a$ = "N" OR a$ = "n" THEN 1990
     FOR i = 1 TO 8: IF d(i) < 0 THEN d(i) = 0
     NEXT i: t = t + d3 + .1
5910 PRINT : PRINT "Device              State of Repair": FOR r1 = 1 TO 8
     GOSUB 8790: PRINT g2$; LEFT$(z$, 25 - LEN(g2$)); INT(d(r1) * 100) * .01
     NEXT r1: PRINT : IF d0 <> 0 THEN 5720
     GOTO 1990
     REM Romulans shooting
6000 IF k3 <= 0 THEN RETURN
     IF d0 <> 0 THEN PRINT "Starbase shields protect the "; ship$; ".": RETURN
     FOR i = 1 TO 3: IF k(i, 3) <= 0 THEN 6200
     h = INT((k(i, 3) / fnd(1)) * (2 + RND(1))): s = s - h: k(i, 3) = k(i, 3) / (3 + RND(0))
     PRINT h; "unit hit on the "; ship$; " from sector"; k(i, 1); ","; k(i, 2)
     IF s <= 0 THEN 6240
     PRINT "      <Shields down to"; s; "units>": IF h < 20 THEN 6200
     IF RND(1) > .6 OR h / s <= .02 THEN 6200
     r1 = fnr(1): d(r1) = d(r1) - h / s - .5 * RND(1): GOSUB 8790
     PRINT "Damage control reports, '"; g2$; " damaged by the hit.'"
6200 NEXT i: RETURN
     REM end of game
6220 PRINT "It is stardate"; t; ".": GOTO 6270
6240 PRINT "The "; ship$; " has been destroyed.  The Federation will be conquered."
     GOTO 6220
6270 PRINT "There were"; k9; "Romulan warship(s) left at the end of your mission."
6290 PRINT : PRINT : IF b9 = 0 THEN 6360
     PRINT "The Federation is in need of a new starship captain for a similar"
     PRINT "mission -- If there is a volunteer, let him step forward and proudly"
     PRINT "say 'aye.'": INPUT "Would you like to try again"; a$: IF a$ = "YES" OR a$ = "Y" OR a$ = "yes" OR a$ = "y" OR a$ = "AYE" OR a$ = "aye" THEN 63
6360 END
6370 PRINT "  Congratulations, Captain "; name$; "!  The last Romulan warship"
     PRINT "menacing the Federation has been destroyed.": PRINT
     PRINT "Your efficiency rating is"; 1000 * (k7 / (t - t0)) ^ 2: GOTO 6290
     REM short-range scan & startup subroutine
6430 FOR i = s1 - 1 TO s1 + 1: FOR j = s2 - 1 TO s2 + 1
     IF INT(i + .5) < 1 OR INT(i + .5) > 8 OR INT(j + .5) < 1 OR INT(j + .5) > 8 THEN 6540
     a$ = ">B<": z1 = i: z2 = j: GOSUB 8830: IF z3 = 1 THEN 6580
6540 NEXT j: NEXT i: d0 = 0: GOTO 6650
6580 d0 = 1: c$ = "docked": e = e0: p = p0
     COLOR 15, 0, 8: PRINT "Shields dropped for docking purposes.": COLOR 7, 0, 8: s = 0: GOTO 6720
6650 IF k3 > 0 THEN c$ = "*RED*": GOTO 6720
     c$ = "green": IF e < e0 * .1 THEN c$ = "yellow"
6720 IF d(2) >= 0 THEN 6770
     PRINT : PRINT "*** Short-Range Sensors Are Out ***": PRINT : RETURN
6770 o1$ = "---------------------------------": PRINT o1$: FOR i = 1 TO 8
     FOR j = (i - 1) * 24 + 1 TO (i - 1) * 24 + 22 STEP 3: PRINT " "; MID$(q$, j, 3); : NEXT j
     ON i GOTO 6850, 6900, 6960, 7020, 7070, 7120, 7180, 7240
6850 PRINT "        Stardate          "; INT(t * 10) * .1: GOTO 7260
6900 PRINT "        Condition          "; c$: GOTO 7260
6960 PRINT "        Quadrent          "; q1; ","; q2: GOTO 7260
7020 PRINT "        Sector            "; s1; ","; s2: GOTO 7260
7070 PRINT "        Photon Torpedoes  "; INT(p): GOTO 7260
7120 PRINT "        Total Energy      "; INT(e + s): GOTO 7260
7180 PRINT "        Shields           "; INT(s): GOTO 7260
7240 PRINT "        Romulans Remaining"; INT(k9)
7260 NEXT i: PRINT o1$: RETURN
     REM library/computer code
7290 IF d(8) < 0 THEN PRINT "Computer disabled": GOTO 1990
7320 INPUT "Computer active and awaiting command"; a: IF a < 0 THEN 1990
     PRINT : h8 = 1: ON a + 1 GOTO 7540, 7900, 8070, 8500, 8150, 7400
     PRINT "Functions available from Library-Computer:"
     PRINT "   0 = Cumulative galactic record"
     PRINT "   1 = Status report"
     PRINT "   2 = Photon torpedo data"
     PRINT "   3 = Starbase nav data"
     PRINT "   4 = Direction/distance calculator"
     PRINT "   5 = Galaxy 'region name' map": PRINT : GOTO 7320
     REM setup to change cum gal record to galaxy map
7400 h8 = 0: g5 = 1: PRINT "                        The Galaxy": GOTO 7550
     REM cum galatic record
7540 REM INPUT "Do you want a hard copy?  Is the TTY on (Y/N)"; a$
     REM IF a$ = "Y" OR a$ = "y" THEN POKE 1229, 2: POKE 1237, 3: REM null 1
     PRINT : PRINT : PRINT "        ";
     PRINT "Computer record of galaxy for quadrent"; q1; ","; q2
     PRINT
7550 PRINT "       1     2     3     4     5     6     7     8"
     o1$ = "     ----- ----- ----- ----- ----- ----- ----- -----"
     PRINT o1$: FOR i = 1 TO 8: PRINT i; : IF h8 = 0 THEN 7740
     FOR j = 1 TO 8: PRINT "   "; : IF z(i, j) = 0 THEN PRINT "***"; : GOTO 7720
     PRINT RIGHT$(STR$(z(i, j) + 1000), 3);
7720 NEXT j: GOTO 7850
7740 z4 = i: z5 = 1: GOSUB 9030: j0 = INT(15 - .5 * LEN(g2$)): PRINT TAB(j0); g2$;
     z5 = 5: GOSUB 9030: j0 = INT(39 - .5 * LEN(g2$)): PRINT TAB(j0); g2$;
7850 PRINT : PRINT o1$: NEXT i: PRINT : POKE 1229, 0: POKE 1237, 1: REM null 0: GOTO 1990
     REM status report
7900 a$ = INKEY$: IF a$ = "" THEN 7900
     PRINT "   Status report:": x$ = "": IF k9 > 1 THEN x$ = "s"
     PRINT "Romulan"; x$; " left:"; k9
     PRINT "Mission must be completed in"; .1 * INT((t0 + t9 - t) * 10); "stardates."
     x$ = "s": IF b9 < 2 THEN x$ = "": IF b9 < 1 THEN 8010
     PRINT "The Federation is maintaining"; b9; "starbase"; x$; " in the galaxy."
     GOTO 5690
8010 PRINT "Your stupidity has left you on your own in the galaxy --"
     PRINT "  You have no starbases left!": GOTO 5690
     REM torpedo, base nav, d/d calculator
8070 IF k3 <= 0 THEN 4270
     x$ = "": IF k3 > 1 THEN x$ = "s"
     PRINT "From "; ship$; " to Romulan warship"; x$; ":"
     h8 = 0: FOR i = 1 TO 3: IF k(i, 3) <= 0 THEN 8480
     w1 = k(i, 1): x = k(i, 2)
8120 c1 = s1: a = s2: GOTO 8220
8150 PRINT "Direction/Distance Calculator:"
     PRINT "You are at quadrent"; q1; ","; q2; "sector"; s1; ","; s2
     PRINT "Please enter": INPUT "  initial coordinates (x,y)"; c1, a
     INPUT "  final coordinates (x,y)"; w1, x
8220 x = x - a: a = c1 - w1: IF x < 0 THEN 8350
     IF a < 0 THEN 8410
     IF x > 0 THEN 8280
     IF a = 0 THEN c1 = 5: GOTO 8290
8280 c1 = 1
8290 IF ABS(a) <= ABS(x) THEN 8330
     PRINT "Direction:"; c1 + (((ABS(a) - ABS(x)) + ABS(a)) / ABS(a)): GOTO 8460
8330 PRINT "Direction:"; c1 + (ABS(a) / ABS(x)): GOTO 8460
8350 IF a > 0 THEN c1 = 3: GOTO 8420
     IF x <> 0 THEN c1 = 5: GOTO 8290
8410 c1 = 7
8420 IF ABS(a) >= ABS(x) THEN 8450
     PRINT "Direction:"; c1 + (((ABS(x) - ABS(a)) + ABS(x)) / ABS(x)): GOTO 8460
8450 PRINT "Direction:"; c1 + (ABS(x) / ABS(a))
8460 PRINT "Distance:"; SQR(x ^ 2 + a ^ 2): IF h8 = 1 THEN 1990
8480 NEXT i: GOTO 1990
8500 PRINT "From "; ship$; " to starbase:": w1 = b4: x = b5: GOTO 8120
     PRINT "Mr. Data reports, 'Sensors show no starbases in this quadrent, sir.'"
     GOTO 1990
     REM find empty space in quadrent (for things)
8590 r1 = fnr(1): r2 = fnr(1): a$ = "   ": z1 = r1: z2 = r2: GOSUB 8830: IF z3 = 0 THEN 8590
     RETURN
     REM insert in string array for quadrent
8670 s8 = INT(z2 - .5) * 3 + INT(z1 - .5) * 24 + 1
     IF LEN(a$) <> 3 THEN PRINT "ERROR": STOP
     IF s8 = 1 THEN q$ = a$ + RIGHT$(q$, 189): RETURN
     IF s8 = 190 THEN q$ = LEFT$(q$, 189) + a$: RETURN
     q$ = LEFT$(q$, s8 - 1) + a$ + RIGHT$(q$, 190 - s8): RETURN
     REM prints device name
8790 ON r1 GOTO 8792, 8794, 8796, 8798, 8800, 8802, 8804, 8806
8792 g2$ = "Warp Engines": RETURN
8794 g2$ = "Short-Range Sensors": RETURN
8796 g2$ = "Long-Range Sensors": RETURN
8798 g2$ = "Phaser Control": RETURN
8800 g2$ = "Photon Tubes": RETURN
8802 g2$ = "Damage Control": RETURN
8804 g2$ = "Shield Control": RETURN
8806 g2$ = "Library-Computer": RETURN
     REM string comparison in quadrent array
8830 z1 = INT(z1 + .5): z2 = INT(z2 + .5): s8 = (z2 - 1) * 3 + (z1 - 1) * 24 + 1: z3 = 0
     IF MID$(q$, s8, 3) <> a$ THEN RETURN
     z3 = 1: RETURN
     REM quadrent name in g2$ from z4,z5 (=q1,q2)
     REM call with g5=1 to get regon name only
9030 IF z5 <= 4 THEN ON z4 GOTO 9040, 9050, 9060, 9070, 9080, 9090, 9100, 9110
     GOTO 9120
9040 g2$ = "Anteres": GOTO 9210
9050 g2$ = "Rigel": GOTO 9210
9060 g2$ = "Procyon": GOTO 9210
9070 g2$ = "Vega": GOTO 9210
9080 g2$ = "Canopus": GOTO 9210
9090 g2$ = "Altair": GOTO 9210
9100 g2$ = "Sagittarius": GOTO 9210
9110 g2$ = "Pollux": GOTO 9210
9120 ON z4 GOTO 9130, 9140, 9150, 9160, 9170, 9180, 9190, 9200
9130 g2$ = "Sirius": GOTO 9210
9140 g2$ = "Deneb": GOTO 9210
9150 g2$ = "Capella": GOTO 9210
9160 g2$ = "Betelgeuse": GOTO 9210
9170 g2$ = "Aldebaran": GOTO 9210
9180 g2$ = "Regulus": GOTO 9210
9190 g2$ = "Arcturus": GOTO 9210
9200 g2$ = "Spica"
9210 IF g5 <> 1 THEN ON z5 GOTO 9230, 9240, 9250, 9260, 9230, 9240, 9250, 9260
     RETURN
9230 g2$ = g2$ + " I": RETURN
9240 g2$ = g2$ + " II": RETURN
9250 g2$ = g2$ + " III": RETURN
9260 g2$ = g2$ + " IV": RETURN
10000 CLS : PRINT : PRINT : PRINT TAB(30); "STAR TREK INSTRUCTIONS": PRINT : PRINT : PRINT
      PRINT "1. When you see 'Command?' printed, enter one of the legal"
      PRINT "   commands (NAV, SRS, LRS, PHA, TOR, SHE, DAM, COM, or XXX)."
      PRINT "2. If you should type in an illegal command, you'll get a short"
      PRINT "   list of the legal commands printed out."
      PRINT "3. Some commands require you to enter data (for example, the"
      PRINT "   'NAV' command comes back with 'Course (1-9).'  If you"
      PRINT "   type in illegal data (such as negative numbers), that command"
      PRINT "   will be aborted."
      PRINT : PRINT "Press any key to continue..."
10195 a$ = INKEY$: IF a$ = "" THEN 10195
      CLS : PRINT
      PRINT "     The galaxy is divided into an 8 x 8 quadrent grid,"
      PRINT "and each quadrent is further divided into an 8 x 8 sector grid."
      PRINT
      PRINT "     You will be assigned a starting point somewhere in the"
      PRINT "galaxy to begin your tour of duty as Captain "; name$; " of"
      PRINT "the starship "; ship$; ".  Your mission: to seek out and"
      PRINT "destroy the fleet of Romulan warships which are menacing"
      PRINT "United Federation of Planets.": PRINT
      PRINT "Make sure that <CAPS LOCK> is down while playing the game."
      PRINT : PRINT "Press any key to continue..."
10355 a$ = INKEY$: IF a$ = "" THEN 10355
      CLS : PRINT
      PRINT "     You have the following commands available to you as captain"
      PRINT "of the starship "; ship$; ":"
      PRINT
      PRINT "\NAV\ Command = Warp Engine Control --"
      PRINT "      Course is set in a circular numerical      4  3  2"
      PRINT "      vector arrangement as shown:                ù ù ù"
      PRINT "      Integer and real values may be               ùùù"
      PRINT "      used.  (Thus course 1.5 is half-         5 ùùù*ùùù 1"
      PRINT "      way between 1 and 2.)                        ùùù"
      PRINT "                                                  ù ù ù"
      PRINT "      Values may approach 9.0, which             6  7  8"
      PRINT "      itself is equivalent to 1.0."
      PRINT "                                                 COURSE"
      PRINT "      One warp factor is the size of"
      PRINT "      one quadrent.  Therefore, to get"
      PRINT "      from quadrent 6,5 to 5,5, you would"
      PRINT "      use course 3, warp factor 1."
      PRINT : PRINT "Press any key to continue..."
10535 a$ = INKEY$: IF a$ = "" THEN 10535
      CLS : PRINT
      PRINT "\SRS\ Command = Short-Range Sensor Scan --"
      PRINT "      shows you a scan of your present quadrent."
      PRINT
      PRINT "      Symbology on your sensor screen is as follows:"
      PRINT "        <*> = your starship"
      PRINT "        +R+ = Romulan warship"
      PRINT "        >B< = Federation starbase (refuel/repair/re-arm)"
      PRINT "         *  = star"
      PRINT
      PRINT "      A condensed 'status report' will also be presented."
      PRINT : PRINT "Press any key to continue..."
10618 a$ = INKEY$: IF a$ = "" THEN 10618
      CLS : PRINT
      PRINT "\LRS\ Command = Long-Range Sensor Scan --"
      PRINT "      Show conditions in space for one quadrent on each side"
      PRINT "      of your starship (which is in the middle of the scan)."
      PRINT "      The scan is coded in the form \###\, where the ones digit"
      PRINT "      is the number of stars, the tens digit is the number of"
      PRINT "      starbases, and the hundreds digit is the number of"
      PRINT "      Romulans."
      PRINT
      PRINT "      Example - 207 = 2 Romulans, no starbases, and 7 stars."
      PRINT : PRINT "Press any key to continue..."
10715 a$ = INKEY$: IF a$ = "" THEN 10715
      CLS : PRINT
      PRINT "\PHA\ Command = Phaser Control --"
      PRINT "      Allows you to destroy the Romulan warships by"
      PRINT "      hitting them with suitably-large units of energy to"
      PRINT "      deplete their shield power.  (Remember, Romulans have"
      PRINT "      phasers too!)"
      PRINT : PRINT "Press any key to continue..."
10770 a$ = INKEY$: IF a$ = "" THEN 10770
      CLS : PRINT
      PRINT "\TOR\ Command = Photon Torpedo Control --"
      PRINT "      Torpedo course is the same as used in warp engine control."
      PRINT "      If you hit the Romulan vessel, it is destroyed and"
      PRINT "      cannot fire back at you.  If you miss, you are subject to"
      PRINT "      its phaser fire.  In either case, you are also subject to"
      PRINT "      the phaser fire of all other Romulans in the quadrent."
      PRINT
      PRINT "      The library-computer (\COM\ command) has an option to"
      PRINT "      compute torpedo trajectory for you (option 2)."
      PRINT : PRINT "Press any key to continue..."
10851 a$ = INKEY$: IF a$ = "" THEN 10851
      CLS : PRINT
      PRINT "\SHE\ Command = Shield Control --"
      PRINT "      Defines the number of energy units to be assigned to the"
      PRINT "      shields.  Energy is taken from the ship's toal energy.  Note"
      PRINT "      that the status display total energy includes shield energy."
      PRINT : PRINT "Press any key to continue..."
10895 a$ = INKEY$: IF a$ = "" THEN 10895
      CLS : PRINT
      PRINT "\DAM\ Command = Damage Control Report --"
      PRINT "      Gives the state of repair of all devices.  Where a negative"
      PRINT "      'State of Repair' shows, that device is temporarily"
      PRINT "      damaged."
      PRINT : PRINT "Press any key to continue..."
10950 a$ = INKEY$: IF a$ = "" THEN 10950
      CLS : PRINT
      PRINT "\COM\ Command = Library-Computer --"
      PRINT "      The library-computer contains six options:"
      PRINT "      Option 0 = Cumulative Galactic Record"
      PRINT "         This option shows computer memory of the results of all"
      PRINT "         previous short- and long-range scans."
      PRINT "      Option 1 = Status Report"
      PRINT "         This option shows the number of remaining Romulans, stardates,"
      PRINT "         and starbases remaining in the game."
      PRINT "      Option 2 = Photon Torpedo Data"
      PRINT "         This option gives directons and distances to all"
      PRINT "         Romulans in your quadrent."
      PRINT "      Option 3 = Starbase Navigation Data"
      PRINT "         This option gives the direction and distance to any"
      PRINT "         starbase in your quadrent."
      PRINT "      Option 4 = Direction/Distance Calculator"
      PRINT "         This option allows you to enter coordinates for"
      PRINT "         directon/distance calculatons."
      PRINT "      Option 5 = Galactic /Region Name/ Map"
      PRINT "         This option prints the names of the sixteen major"
      PRINT "         galactic regions referred to in this game."
      PRINT : PRINT "Press any key to continue..."
11170 a$ = INKEY$: IF a$ = "" THEN 11170
      RETURN

SUB ActivateCapsLock
    DEF SEG = &H40
    POKE &H17, (PEEK(&H17) OR 64)
    DEF SEG
END SUB

